package com.ruoyi.web.controller.construction.supertube;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.construction.Team;
import com.ruoyi.system.domain.zhuangxiumain.financialSupport.CooperativeBrand;
import com.ruoyi.system.domain.zhuangxiumain.financialSupport.ProductFlow;
import com.ruoyi.system.domain.zhuangxiumain.shopMain.ProductInfo;
import com.ruoyi.system.domain.zhuangxiumain.shopMain.SupplierInfo;
import com.ruoyi.system.service.vantservice.financialSupport.ApiCooperativeBrandService;
import com.ruoyi.system.service.vantservice.financialSupport.ProductFlowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 后台合作品牌
 */
@Api(value = "超管合作伙伴接口", tags = {"超管合作伙伴接口"})
@RestController
@RequestMapping("/super/CooperativeBrand")
public class SuperCooperativeBrandController  extends BaseController {
    @Autowired
    private ProductFlowService productFlowService;
    @Autowired
    private ApiCooperativeBrandService apiCooperativeBrandService;
    /**
     * 查询全部合作伙伴
     * @return
     */
    //@PreAuthorize("@ss.hasPermi('super:team:listTwo')")
    @GetMapping("/getCooperativeAll")
    public TableDataInfo getCooperativeAll()
    {
        startPage();
        List<CooperativeBrand> list = apiCooperativeBrandService.selectCooperativeBrandByNull();
        return getDataTable(list);
    }

    //@PreAuthorize("@ss.hasPermi('super:goodsstore:edit')")
    @Log(title = "合作伙伴", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody CooperativeBrand cooperativeBrand )
    {
        return toAjax(apiCooperativeBrandService.updateState(cooperativeBrand.getCooperativeId(),cooperativeBrand.getCooperativeState()));
    }

    /**
     * 删除合作伙伴
     * @param ids
     * @return
     */
    @PreAuthorize("@ss.hasPermi('group:booking:remove')")
    @Log(title = "删除合作伙伴", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove/{productIds}")
    public AjaxResult deleteCopera(@PathVariable Integer[] productIds){
        return toAjax(apiCooperativeBrandService.deleteCooperativeBrand(productIds));
    }

    @ApiResponses({@ApiResponse(code = 200, message = "正常", response = CooperativeBrand.class)})
    @ApiOperation(value = "新增合作伙伴信息")
    //@PreAuthorize("@ss.hasPermi('shopping:goods:addpi')")
    @Log(title = "新增合作伙伴", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult addCoopera(@RequestBody CooperativeBrand cooperativeBrand){
        cooperativeBrand.setCooperativeState("1");
        return toAjax(apiCooperativeBrandService.addCooperativeBrand(cooperativeBrand));
    }

    /**
     * 查询申请流程
     * @return
     */
    @GetMapping("/getProduct")
    public AjaxResult getProduct(){
        return  AjaxResult.success(productFlowService.getProductFlowAll());
    }

    /**
     * 修改申请流程
     * @param productFlow
     * @return
     */
    @ApiResponses({@ApiResponse(code = 200, message = "正常", response = ProductFlow.class)})
    @ApiOperation(value = "修改申请流程")
    //@PreAuthorize("@ss.hasPermi('shopping:goods:addpi')")
    @Log(title = "修改申请流程", businessType = BusinessType.UPDATE)
    @PutMapping("/updateProductFlow")
    public AjaxResult updateProductFlow(@RequestBody ProductFlow productFlow){
        return AjaxResult.success(productFlowService.updateProductsFlowById(productFlow));
    }
}
